//
//  RoadShowDetailHeadView.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/7/22.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "RoadShowDetailHeadView.h"
#import "HomeProjectMarkCell.h"

@implementation RoadShowDetailHeadView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    self.backgroundColor = [UIColor whiteColor];
    self.markArray = @[@"O2O"].mutableCopy;
    
    //  头像
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 70, 70)];
    self.headImageView.center = CGPointMake(self.headImageView.width / 2 + 10, 50);
    self.headImageView.image = [UIImage imageNamed:@"touxiang"];
    [self addSubview:self.headImageView];
    self.headImageView.layer.cornerRadius = (kScreenWidth - 20)/12;
    self.headImageView.layer.masksToBounds = YES;
    
    // 标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, kScreenWidth - self.headImageView.maxX - 10, self.headImageView.height /3)];
    self.titleLabel.text = @"海水专卖";
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.titleLabel];
    
    
    //评分
    self.score = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 100, 20, 80, 20)];
    self.score.text = @"评分 : 9";
    self.score.font = [UIFont systemFontOfSize:13];
    self.score.textColor = [UIColor redColor];
    self.score.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.score];
    
    // 标签
    UICollectionViewFlowLayout *markLayout = [[UICollectionViewFlowLayout alloc]init];
    markLayout.itemSize = CGSizeMake(self.titleLabel.width / 5 , self.titleLabel.height);
    markLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    markLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 5);
    self.markCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(self.titleLabel.x, self.titleLabel.maxY, self.titleLabel.width, self.titleLabel.height) collectionViewLayout:markLayout];
    self.markCollectionView.delegate = self;
    self.markCollectionView.dataSource = self;
    self.markCollectionView.backgroundColor = [UIColor whiteColor];
    [self.markCollectionView registerClass:[HomeProjectMarkCell class] forCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class])];
    [self addSubview:self.markCollectionView];
    
    // 分类名
    UILabel *groupLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.markCollectionView.x, self.markCollectionView.maxY + 2, self.headImageView.width, self.titleLabel.height)];
    groupLabel.backgroundColor = COLOR_RGBA(0, 228, 161, 1);
    groupLabel.text = @"已审核";
    groupLabel.font = [UIFont systemFontOfSize:12];
    groupLabel.textAlignment = 1;
    groupLabel.textColor = [UIColor whiteColor];
    groupLabel.layer.cornerRadius = 5;
    groupLabel.layer.masksToBounds = YES;
    [self addSubview:groupLabel];
    
    // 已关注图标
    UIImageView *focusImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth / 9 * 5, groupLabel.y, self.headImageView.width / 7 * 2, self.headImageView.width / 7 * 2)];
    focusImageView.image = [UIImage imageNamed:@"guanzhu"];
    [self addSubview:focusImageView];
    
    // 已关注人数
    self.focusLabel = [[UILabel alloc]initWithFrame:CGRectMake(focusImageView.maxX, focusImageView.y, kScreenWidth / 9 * 2 - focusImageView.width, focusImageView.height)];
    self.focusLabel.text = [NSString stringWithFormat:@"  已关注 : 2"];
    self.focusLabel.font = [UIFont systemFontOfSize:10];
    self.focusLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.focusLabel];
    
    // 已查看图标
    UIImageView *funsImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth / 9 * 7, groupLabel.y, focusImageView.width, focusImageView.height)];
    funsImageView.image = [UIImage imageNamed:@"fensi"];
    [self addSubview:funsImageView];
    
    // 已查看人数
    self.funsLabel = [[UILabel alloc]initWithFrame:CGRectMake(funsImageView.maxX, funsImageView.y, self.focusLabel.width , self.focusLabel.height)];
    self.funsLabel.text = [NSString stringWithFormat:@"  粉丝 : 3"];
    self.funsLabel.font = [UIFont systemFontOfSize:10];
    self.funsLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.funsLabel];
    
    //横线
    self.line = [[UITextField alloc] initWithFrame:CGRectMake(5, self.headImageView.maxY + 10, kScreenWidth - 10, 1)];
    self.line.backgroundColor = [UIColor colorWithWhite:0.935 alpha:1.000];
    [self addSubview:self.line];
    
    //距开始
    
    self.downWord = [[UILabel alloc] initWithFrame:CGRectMake(20, self.line.maxY + 10, 80, 25)];
    //self.downWord.backgroundColor = [UIColor yellowColor];
    self.downWord.text = @"距开始:";
    self.downWord.textColor = [UIColor grayColor];
    self.downWord.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.downWord];
    
    //倒计时 天 时 分 秒
    self.dayLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2 - 107, self.downWord.maxY + 15, 45, 30)];
    self.dayLabel.backgroundColor = [UIColor lightGrayColor];
    [self.dayLabel setTextColor:[UIColor whiteColor]];
    self.dayLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.dayLabel];
    
    self.dot1 = [[UILabel alloc] initWithFrame:CGRectMake(self.dayLabel.maxX + 5, self.dayLabel.y + 10, 5, 5)];
    self.dot1.layer.cornerRadius = 2.5;
    self.dot1.layer.masksToBounds = YES;
    self.dot1.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.dot1];
    
    self.dot2 = [[UILabel alloc] initWithFrame:CGRectMake(self.dayLabel.maxX + 5, self.dayLabel.maxY - 10, 5, 5)];
    self.dot2.backgroundColor = [UIColor lightGrayColor];
    self.dot2.layer.cornerRadius = 2.5;
    self.dot2.layer.masksToBounds = YES;
    [self addSubview:self.dot2];
    
    self.hourLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2 - 50, self.downWord.maxY + 15, 45, 30)];
    self.hourLabel.backgroundColor = [UIColor lightGrayColor];
    self.hourLabel.textAlignment = NSTextAlignmentCenter;
    [self.hourLabel setTextColor:[UIColor whiteColor]];
    [self addSubview:self.hourLabel];
    
    self.dot3 = [[UILabel alloc] initWithFrame:CGRectMake(self.hourLabel.maxX + 5, self.hourLabel.y + 10, 5, 5)];
    self.dot3.layer.cornerRadius = 2.5;
    self.dot3.layer.masksToBounds = YES;
    self.dot3.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.dot3];
    
    self.dot4 = [[UILabel alloc] initWithFrame:CGRectMake(self.hourLabel.maxX + 5, self.hourLabel.maxY - 10, 5, 5)];
    self.dot4.backgroundColor = [UIColor lightGrayColor];
    self.dot4.layer.cornerRadius = 2.5;
    self.dot4.layer.masksToBounds = YES;
    [self addSubview:self.dot4];
    
    self.minuteLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2+7, self.downWord.maxY + 15, 45, 30)];
    self.minuteLabel.backgroundColor = [UIColor lightGrayColor];
    [self.minuteLabel setTextColor:[UIColor whiteColor]];
    self.minuteLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.minuteLabel];
    
    self.dot5 = [[UILabel alloc] initWithFrame:CGRectMake(self.minuteLabel.maxX + 5, self.hourLabel.y + 10, 5, 5)];
    self.dot5.layer.cornerRadius = 2.5;
    self.dot5.layer.masksToBounds = YES;
    self.dot5.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.dot5];
    
    self.dot6 = [[UILabel alloc] initWithFrame:CGRectMake(self.minuteLabel.maxX + 5, self.hourLabel.maxY - 10, 5, 5)];
    self.dot6.backgroundColor = [UIColor lightGrayColor];
    self.dot6.layer.cornerRadius = 2.5;
    self.dot6.layer.masksToBounds = YES;
    [self addSubview:self.dot6];
    
    self.secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2 + 64, self.downWord.maxY + 15, 45, 30)];
    self.secondLabel.backgroundColor = [UIColor lightGrayColor];
    [self.secondLabel setTextColor:[UIColor whiteColor]];
    self.secondLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.secondLabel];
    //路演时间
    
    self.roadShowTime = [[UILabel alloc] initWithFrame:CGRectMake(20, self.secondLabel.maxY + 15, kScreenWidth - 40, 20)];
    //self.roadShowTime.backgroundColor = [UIColor yellowColor];
    self.roadShowTime.text = @"路演时间: 2016-07-15 11:40:00";
    self.roadShowTime.textColor = [UIColor grayColor];
    self.roadShowTime.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.roadShowTime];
    
    //路演时长
    
    self.timeLenth = [[UILabel alloc] initWithFrame:CGRectMake(20, self.roadShowTime.maxY+5, kScreenWidth - 40, 20)];
    //self.timeLenth.backgroundColor = [UIColor yellowColor];
    self.timeLenth.text = @"路演时长: 12分钟";
    self.timeLenth.textColor = [UIColor grayColor];
    self.timeLenth.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.timeLenth];
    
    
}

#pragma mark - markCollectionView 代理方法

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.markArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    HomeProjectMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class]) forIndexPath:indexPath];
    cell.markContent = self.markArray[indexPath.row];
    
    return cell;
    
}
@end
